<?php

//  This example script extends what was explained in the previous one by demonstrating more features



// Before running, check the paths in the demo_initialization file
include('demo_initialization.php');



// This will demonstrate use of a custom submission detection function
function my_custom_tipoff_function( ){
  if( count($_POST) ){ return 'post'; };
  else return false;
}



// The Imp constructor has the format Imp(string $smarty, string $imp_name, string $tipoff_function_handle, array $tipoff_function_arguments);
// where
//   $smarty is the smarty object to render the page
//   $imp_name is the handle by which imp_tags will reference to associate themselves with particular imps (optional if you only have one imp)
//   $tipoff_function_handle is the name of a function (or an array containing a class name and a method name) that will determine if and where user submissions are coming in
//   $tipoff_function_arguments is an array of arguments to be passed to the tipoff function
$survey_imp = new Imp($smarty, 'survey', 'my_custom_tipoff_function', null);
$email_imp  = new Imp($smarty, 'email' , 


$imp->invalidator('state', 'longer_than'        , array(imp_oot('model'), 3   ));
$imp->validator(  'state' , 'empty'             , array(imp_oot('model')      )); // This Imp is in optimistic mode (the default), so a form is valid until proven invalid, and validators trump invalidators when referring to the same requirement.  Thus, if the user supplies no phone number, then the invalidator on previous line is triggered, but this validator overrides it (because the 



if( $imp->submitted() ){
  echo'YOU HAVE SUBMITTED THIS FORM...<BR/>';
  if( $imp->validate() ){
    echo 'AND IT WAS VALID!';
    exit();
  }
  ECHO 'BUT THERE WERE ERRORS:<BR/>';
}



$smarty->display('full-featred_form.tpl');

?>
